/**
 * 
 */
package org.ycsoft.MetroidReader;

import java.util.ArrayList;

/**
 * Represents a stop record in a metroid file
 * @author allad
 *
 */
public class StopRecord {
	private String stopName;
	private int stopId;
	
	private String coordinates;
	private String lineIds;
	
	public StopRecord(){
		
	}
	
	public void setStopName(String value){
		stopName = value;
	}
	
	public String getStopName(){
		return stopName;
	}
	
	public void setStopId(int value){
		stopId = value;
	}
	
	public void setStopId(String value) throws InvalidFileException{
		if(value == null)
			return;
		value = value.trim();
		try{
			stopId = Integer.parseInt(value);
		}catch(Exception e){
			throw new InvalidFileException("Invalid stop id");
		}
	}
	
	public int getStopId(){
		return stopId;
	}
	
	public void setCoordinates(String value){
		coordinates = value;
	}
	
	public String getCoordinates(){
		return coordinates;
	}
	
	public ArrayList getLinesIds(){
		ArrayList retVal = new ArrayList();
		
		if(lineIds.contains(",")){
			String[] ids = lineIds.split(",");
			for(String s : ids){
				try{
					int i = Integer.parseInt(s);
					retVal.add(i);
				}catch(NumberFormatException ne){
					//ignore
				}
			}
		}
		return retVal;
	}
	
	public void setLinesIds(String value){
		lineIds = value;
	}
	
	public String toString(){
		return stopName;
	}
}
